﻿<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.util.Util,com.newcrm.bean.*,java.util.List,java.util.Map" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<Map<String, Object>> taskCategory = companyInfo.taskCategorys;
  List<User> users = companyInfo.users;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>最新动态</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="renderer" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/qikebao.ico" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/all.css?ver=<%=Const.VERSION%>">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/datepicker.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap-datetimepicker.min.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/magnific-popup.css">
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-ui.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.bootstrap-growl.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/moment.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datetimepicker.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/daterangepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.magnific-popup.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.cookie.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/popbox.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/activity.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/pageNavi.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/common.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/rightTask.js?ver=<%=Const.VERSION%>"></script>
  <script>
    var pageSize = <%=Const.PAGE_SIZE%>;
    var loginUserId = '<%=user.userId%>';
    var allUsers = new Array();
    <%if (users != null) {
        for (User u:users) { %>
    allUsers.push({id:"<%=u.userId%>",name:"<%=Util.UEncode(u.name)%>",photo:"<%=u.imgPath%>"});
    <%  }} %>
  </script>
</head>
<body class="parties">
  <jsp:include page="topNavi.jsp" flush="true"/>
  <div class="main-page">
    <table>
    <tr>
      <td class="main-body">
        <div class="topnavi">
<% if (!user.isAdmin && !user.isGroupAdmin) { %>
          <div class='leftMenu'><span>最新动态</span></div>
<% } else {%>
          <div class='popbox leftMenu'>
            <a class='open' href="#"><span id="viewmodeMessage">我的动态</span> <i class="fa fa-chevron-down"></i></a>
            <div class='collapse'>
              <div class='box'>
                <div class='arrow'></div><div class='arrow-border'></div>
                <form>
                <h1>请选择查看方式：</h1>
                <p style="text-align:left;padding:5px 0px;margin:0px;">
                  <select id="memeberId" >
                    <option value="<%=user.userId%>">我的动态</option>
                  <%
                    String groupName = null;
                    for (User u : users) {
                      if (u.userId.equals(user.userId)) {
                        continue;
                      }
                      if (!companyInfo.isGroupAdmin(user, u.groupId)) {
                        continue;
                      }
                      String gn = companyInfo.getGroupName(u);
                      if (groupName == null) {
                        if (gn != null) {
                          groupName = gn;  %>
                    <optgroup label="<%=Util.HTMLEncode(groupName)%>">
                  <%
                        }
                      } else {
                        if (!groupName.equals(gn)) {
                          groupName = gn; %>
                    </optgroup>
                    <optgroup label="<%=Util.HTMLEncode(groupName)%>">
                  <%
                        }
                      }
                  %>
                    <option value="<%=u.userId%>"><%=Util.HTMLEncode(u.name)%>的动态</option>
                  <%}
                    if (groupName != null && groupName.length() > 0) { %>
                    </optgroup>
                  <%}%>
                  </select>
                </p>
                </form>
              </div>
            </div>
          </div>
          <div class="clearfix"></div>
<%}%>
        </div>
        <div id="notes_loading" class="loading" style="display:none;">
          <div class="liner">
            <h3>加载中...</h3>
            <img alt="加载中" src="<%=request.getContextPath()%>/images/dots-white.gif" />
          </div>
        </div>
        <div id="recordings" class="recordings">
          <table class="list_view" cellspacing="0">
            <tbody id="note_list"></tbody>
          </table>
        </div>
        <div class="pagination right"><div class="page-bottom" id="pageNavi"></div></div>
      </td>
      <td class="main-sidebar">
        <div class="content">
          <h2 class="clearfix">任务</h2>
          <div class="tasklist overdue" id="overdueTasks">
            <h6> 已过期 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="todayTasks">
            <h6> 今天 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="tomorrowTasks">
            <h6> 明天 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="thisWeekTasks">
            <h6> 本周 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="nextWeekTasks">
            <h6> 下周 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="laterTasks">
            <h6> 以后 </h6>
            <ul class="tasks"></ul>
          </div>
        </div>
      </td>
    </tr>
    </table>
  </div>

  <div style="display:none;">
  <table>
  <tr class="recording" id="cloneTaskNote">
    <td class="type"><span class="sprite task"></span></td>
    <td class="content">
      <span class="re"><a href="#" class="permalink"></a></span>
      <span class="body taskNote"><span class="excerpt"></span> <a class="delete" href="#"><i class="fa fa-trash-o"></i></a></span>
    </td>
    <td class="date"></td>
  </tr>
  <tr class="recording" id="cloneUserNote">
    <td class="type"><span class="sprite"></span></td>
    <td class="content">
      <span class="re"><a href="" class="permalink"></a></span>
      <span class="body"><span class="excerpt"></span></span>
      <span class="by"></span>
    </td>
    <td class="date"></td>
  </tr>
  <tr class="recording" id="cloneDealNote">
    <td class="type"><span class="sprite deal"></span>
    </td>
      <td class="content">
        <span class="re"><a href="" class="permalink"></a></span>
        <span class="body"></span>
      </td>
      <td class="date"></td>
  </tr>
  </table>
  </div>

  <div class="movebox" id="updateTask">
    <div class='arrow'></div><div class='arrow-border'></div>
    <form class="task">
      <h3>修改任务</h3>
      <p class="task_body">
        <input id="update_taskId" type="hidden" value="" />
        <input class="autofocus" id="update_taskTitle" size="25" type="text" />
      </p>
      <div>
        <h5>到期时间</h5>
        <p>
          <div class="datetimepicker_container"><input class="autofocus dueDate" id="update_dueDate" size="25" type="text" /></div>
        </p>
        <h5>任务负责人</h5>
        <p>
          <select id="update_responsibleUserId" class="responsibleUserId"></select></p>
        <h5>任务分类</h5>
        <p>
          <select id="update_categoryId" class="categoryId"></select>
          <% if (user.isAdmin) {%>
          <a href="<%=request.getContextPath()%>/taskcategory" class="edit_categories">编辑分类</a>
          <% }%>
        </p>
        <p>
          <input class="checkbox" id="update_taskVisible" type="checkbox" value="1" />
          <label for="update_taskVisible">所有人可以看见这个任务</label>
        </p>
      </div>
      <div class="submit">
        <a id="update_task_button" class="button blue small closePopbox" href="#"><i class="fa fa-check"></i> 修改任务</a>
        &nbsp;&nbsp;<a href="#" class="closePopbox" id="update_task_cancel_link">取消</a>
      </div>
    </form>
  </div>
</body>
</html>